//
//  ProjectWebService.m
//  YYZB
//
//  Created by 顾悦 on 16/3/30.
//
//

#import "ProjectWebService.h"

@implementation ProjectWebService

- (void)getCategoriesByServiceID:(NSString *)serviceID
               completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder {
    NSString *URL = @"Service/ServiceCategoryList";
    NSDictionary *params = @{
                             @"ServiceCat1Id": serviceID
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:NO];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

- (void)getProjectsByServiceID:(NSString *)serviceID
                    categoryID:(NSString *)categoryID
                   communityId:(NSString *)communityId
                     pageIndex:(NSNumber *)pageIndex
                      pageSize:(NSNumber *)pageSize
             completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder {
    NSString *URL = @"Service/GetServiceProductList";
    NSDictionary *params = @{
                             @"ServiceCat1Id": serviceID,
                             @"ServiceCat2Id": categoryID,
                             @"CommunityId": communityId,
                             @"PageSize": pageSize,
                             @"PageIndex": pageIndex
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:NO];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

@end
